<?php
namespace Hawk\Controller;
use \Hawk\Controller\IndexController;
class CommunicateLogController extends IndexController 
{
	/**
     * 客服沟通记录添加
     * @author hawk <2271030162@qq.com>
     * @return mix
     */
	public function chatadd(){
		if(IS_PSOT && !empty($_POST)){
			$model=D("Hawk/CommunicateLog");
			if($model->create(I('post.'), 1))
    		{
    			if($id = $model->add())
    			{
                    $content = "添加客服沟通记录(".$id.")";
                    hawk_operation_log(session('id'),hawk_get_ip(),$content);
    				$this->success('添加成功！', U('Service/lst?p='.I('get.p')));
    				exit;
    			}
    		}
    		$this->error($model->getError());

		}
		if(!empty(I("get.id"))){
			$tmodel = M('ChatType');
			$type = $tmodel->select();
			$this->assign('type',$type);
			$this->assign('cus_id',I("get.id"));
			$this->display();
		}
	}
	/**
     * 客服沟通记录修改
     * @author hawk <2271030162@qq.com>
     * @return mix
     */
	public function chatedit(){
		$id = I('get.id');
        $model=D("Hawk/CommunicateLog");
        if(IS_POST && !empty($_POST))
        {
            if($model->create(I('post.'), 2))
            {
                if($model->save() !== FALSE)
                {
                    $content = "修改客服沟通记录(".$_POST['id'].")";
                    hawk_operation_log(session('id'),hawk_get_ip(),$content);
                    $this->success('修改成功！', U('Service/lst', array('p' => I('get.p', 1))));
                    exit;
                }
            }
            $this->error($model->getError());
        }
        $chatInfo=$model->find($id);
        $this->assign('chatInfo',$chatInfo);
        $tmodel = M('ChatType');
		$type = $tmodel->select();
		$this->assign('type',$type);
        $this->display();
	}
}